﻿using System.Web.Mvc;

namespace Supermodel.MVC.FormModels
{
    public class TextFormModel : IFormModelDisplayTemplate
    {
        public TextFormModel()
        {
            Text = "";
            WrapInDiv = true;
            DivClass = "";
        }
        
        public string Text { get; set; }
        public bool WrapInDiv { get; set; }
        public string DivClass { get; set; }

        public override string ToString()
        {
            if (string.IsNullOrWhiteSpace(Text)) return "";
            return WrapInDiv ? string.Format("<div {0}> {1} </div>", string.IsNullOrEmpty(DivClass) ? "" : "class='" + DivClass + "'", Text) : Text;
        }

        public bool GetIDisplayTemplateImplemented(){ return true; }
        public MvcHtmlString DisplayTemplate(HtmlHelper html)
        {
            return MvcHtmlString.Create(ToString());
        }
    }
}
